home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*\
- | Options.cpp - CtlHTML(tm) Control Library Test Program |
- | Windmill Point Software, Alburg, VT 05440 |
- | Copyright (c) 1999, Windmill Point Software |
- | All Rights Reserved. |
- \*---------------------------------------------------------------------------*/
-
- #include "stdafx.h"
- #include "CtlHTML Demo.h"
- #include "DevUI.h"
- #include "Options.h"
- #include "..\CtlHtml.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CGeneralOptions property page
-
- IMPLEMENT_DYNCREATE(CGeneralOptions, CPropertyPage)
-
- BEGIN_MESSAGE_MAP(CGeneralOptions, CPropertyPage)
- //{{AFX_MSG_MAP(CGeneralOptions)
- ON_WM_ACTIVATE()
- ON_BN_CLICKED(IDC_FONT_BROWSE, OnFontBrowse)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CGeneralOptions::CGeneralOptions() : CPropertyPage(CGeneralOptions::IDD)
- {
- //{{AFX_DATA_INIT(CGeneralOptions)
- m_RightJustify = -1;
- m_FontSize = 0;
- m_Typeface = _T("");
- m_DisableControls = FALSE;
- m_DitherGraphics = FALSE;
- m_HelpPath = _T("");
- m_UseDisabled3D = FALSE;
- //}}AFX_DATA_INIT
- }
-
- CGeneralOptions::~CGeneralOptions()
- {
- }
-
- void CGeneralOptions::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CGeneralOptions)
- DDX_Radio(pDX, IDC_CENTER, m_RightJustify);
- DDX_Text(pDX, IDC_FONT_SIZE, m_FontSize);
- DDV_MinMaxUInt(pDX, m_FontSize, 6, 24);
- DDX_Text(pDX, IDC_TYPEFACE, m_Typeface);
- DDX_Check(pDX, IDC_DISABLE_CONTROLS, m_DisableControls);
- DDX_Check(pDX, IDC_DITHER_GRAPHICS, m_DitherGraphics);
- DDX_Text(pDX, IDC_HELP_PATH, m_HelpPath);
- DDX_Check(pDX, IDC_USE_3D, m_UseDisabled3D);
- //}}AFX_DATA_MAP
- }
-
- void CGeneralOptions::OnFontBrowse()
- {
- CClientDC dc(this);
- LOGFONT lf;
-
- // init font info
- ZeroMemory(&lf, sizeof(lf));
- lf.lfHeight = -MulDiv(m_FontSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
- lf.lfWeight = FW_NORMAL;
- _tcscpy(lf.lfFaceName, m_Typeface);
-
- // display font common dialog
- CFontDialog dialog(&lf);
- if (dialog.DoModal() == IDOK)
- {
- m_Typeface = dialog.GetFaceName();
- m_FontSize = dialog.GetSize() / 10;
-
- CWnd *pWnd;
- CString temp;
-
- temp.Format(_T("%d"), m_FontSize);
- if ((pWnd = GetDlgItem(IDC_TYPEFACE)) != 0)
- pWnd->SetWindowText(m_Typeface);
- else
- ASSERT(FALSE);
-
- if ((pWnd = GetDlgItem(IDC_FONT_SIZE)) != 0)
- pWnd->SetWindowText(temp);
- else
- ASSERT(FALSE);
- }
- }
-
- BOOL CGeneralOptions::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- CSpinButtonCtrl *pSpin;
-
- if ((pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_FONTSIZE_SPIN)) != 0)
- {
- ASSERT_VALID(pSpin);
- pSpin->SetRange(6, 24);
- }
- else
- ASSERT(FALSE);
-
- return TRUE;
- }
-
- void CGeneralOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CPropertyPage::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // COptions
-
- IMPLEMENT_DYNAMIC(COptions, CMcPropertySheet)
-
- BEGIN_MESSAGE_MAP(COptions, CMcPropertySheet)
- //{{AFX_MSG_MAP(COptions)
- ON_WM_ACTIVATE()
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- COptions::COptions(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
- :CMcPropertySheet(nIDCaption, pParentWnd, iSelectPage)
- {
- AddPage(&m_General);
- }
-
- COptions::COptions(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
- :CMcPropertySheet(pszCaption, pParentWnd, iSelectPage)
- {
- AddPage(&m_General);
- }
-
- COptions::~COptions()
- {
- }
-
- BOOL COptions::OnInitDialog()
- {
- // remove the Apply button
- RemoveApplyButton();
-
- // init the dialog
- BOOL bResult = CMcPropertySheet::OnInitDialog();
-
- // handle window placement
- CMcWindowPlacement wp;
- wp.RestoreWindowPlacement(_T("Options"), _T("WindowPlacement"), this, TRUE);
-
- // init the dialog
- return bResult;
- }
-
- void COptions::OnDestroy()
- {
- // handle window placement
- CMcWindowPlacement wp;
- wp.SaveWindowPlacement(_T("Options"), _T("WindowPlacement"), this);
-
- CMcPropertySheet::OnDestroy();
- }
-
- void COptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {
- CMcPropertySheet::OnActivate(nState, pWndOther, bMinimized);
- if (DisableControls)
- CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
- }
-